﻿using Microsoft.AspNetCore.SignalR;
using SignalRecharts.Models;
using System.Threading;
using System.Threading.Tasks;

namespace SignalRecharts.Hubs
{
    public class ChatHub : Hub
    {
        DataSerices objDataSerices = new DataSerices();

      
        public async Task SendData()
        {
            string data1 = null;
            string data2 = null;
            //int data3 = 0;
            while (true)
            {
                data1 = objDataSerices.Unfinished(); //未完成(待齐套,待签单,待包装,待出箱单,待通知)
                await Clients.All.SendAsync("Unfinished", data1);//调用客户端Unfinished方法，向客户端发送数据

                //每天接收任务，每天派发，每天接收任务未完成，每天派发未完成
                data2 = objDataSerices.Everyday();
                await Clients.All.SendAsync("Everyday", data2);
                ////总收敛周期
                //data3 = objDataSerices.Convergence();
                //await Clients.All.SendAsync("Convergence", data3);

                ////今日下达任务总项数
                //await Clients.All.SendAsync("L1", "1981");
                Thread.Sleep(10000);
            }
            
        }
    }
}
